package com.ctshk.rpc.air.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.air.entity.AirProductSaleStrategy;
import com.ctshk.rpc.air.entity.MainDataAirAirport;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author
 * @since
 */
public interface MainDataAirAirportMapper extends BaseMapper<MainDataAirAirport> {

    /**
     * 国家与机场信息查询
     * @param name
     * @return
     */
    @Select("select \n" +
            "t.id, t.parent_id, t.country_id, t.country_simple, t.country_traditional, t.country_en, t.country_pinyin,\n" +
            "t.city_simple, t.city_traditional, t.city_pinyin, t.city_en, td.airport_name,\n" +
            "td.airport_code, td.custom_name \n" +
            "from \n" +
            " `ctshk-cloud`.t_sys_area t left join `ctshk-cloud`.t_main_data_air_airport td on t.parent_id = td.custom_id \n" +
            "where \n" +
            "t.country_simple like CONCAT('%',#{name},'%') or \n" +
            "t.country_traditional like CONCAT('%',#{name},'%') or \n" +
            "t.country_en like CONCAT('%',#{name},'%') or \n" +
            "t.country_pinyin like CONCAT('%',#{name},'%') or \n" +
            "t.city_simple like CONCAT('%',#{name},'%') or \n" +
            "t.city_traditional like CONCAT('%',#{name},'%') or \n" +
            "t.city_pinyin like CONCAT('%',#{name},'%') or \n" +
            "t.city_en like CONCAT('%',#{name},'%') or \n" +
            "td.airport_name like CONCAT('%',#{name},'%') or \n" +
            "td.airport_code like CONCAT('%',#{name},'%') or \n" +
            "td.custom_name like CONCAT('%',#{name},'%')  \n" +
            "group by td.airport_code ")
    List<MainDataAirAirport> getAirportList(@Param("name") String name);
}
